home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1994 November / Cd Ware (Nro. 2) - Epimundo.iso / DOS / PG / CHART.ZIP / CFLOW2.86 < prev    next >
Encoding:
Text File  |  1993-01-04  |  14.4 KB  |  492 lines

  1.  
  2.         ;write current and neighbour boxes with options to screen
  3.  
  4. write_chart:
  5.         call get_current_routes    ;copy current route data to route store
  6.         mov w stem_start,1    ;write 3 top vertical double bars
  7.         mov b cursor_pos,39    ;store cursor coords for stem
  8.         mov cx,2    ;load arrow key jump address count
  9.         mov di,o akey_jump    ;load pointer to cursor key table
  10.         mov es,ax,cs
  11.         xor ax,ax    ;clear register
  12.         rep
  13.         stosw    ;clear jump addresses
  14.  
  15.         ;clear screen
  16.  
  17.         mov w cursor_pos+1,ax
  18.         mov b command_line,al    ;clear command row string
  19.         mov b descripter_string,al    ;clear box descripter string buffer
  20.         call cls    ;clear the screen
  21.         mov es,ax,cs    ;copy code segment
  22.  
  23.         ;write options to screen
  24.  
  25.         mov cx,option_count    ;load loop count
  26.         xor bx,bx    ;load offset to options available
  27.         mov di,o command_line    ;load offset to command line
  28. a1:
  29.         push cx    ;save loop count
  30.         cmp b[bx+option_array+2],1    ;is option available?
  31.         jne >a2    ;check if it is existing route if not
  32.  
  33.         ;check if C option is 'create' or 'cancel'
  34.  
  35.         xor dx,dx    ;assume 'create' option
  36.         cmp bx,2    ;is option create/cancel?
  37.         jne >a3    ;check for 'A' option if not
  38.         cmp w box_save,0    ;is it 'create' option?
  39.         je >a3    ;calculate offset to string if it is
  40.         mov dx,option_count*2-2    ;load offset to cancel string
  41.  
  42.         ;create option string and add it to command line
  43.  
  44. a3:
  45.         mov si,bx    ;load offset to options array
  46.         add si,dx    ;add cancel offset
  47.         mov si,w[si+options_table]    ;load offset to option
  48.  
  49.         ;get length of option string
  50.  
  51.         push si    ;save offset to start of string
  52. a3:
  53.         lodsb    ;load character from string
  54.         or al,al    ;is it last character
  55.         jne a3    ;get next character if not
  56.         mov cx,si    ;load offset to end of string
  57.         dec cx    ;move it over zero byte
  58.         pull si    ;restore offset to start of string
  59.         sub cx,si    ;calculate length of string
  60.  
  61.         ;check if option string can be added to command line
  62.  
  63.         mov ax,di    ;load offset to end of command line
  64.         sub ax,o command_line    ;calculate length of string
  65.         add ax,cx    ;add it to option string length
  66.         add ax,2    ;add 2 for full stop and space
  67.         cmp ax,78    ;can option string be added?
  68.  
  69.         ;write command line to screen
  70.  
  71. if a        call write_command_line    ;write remainder of options
  72.         rep
  73.         movsb    ;copy option string
  74.         mov ax,0202eh    ;load option terminator string
  75.         stosw    ;write it to end of option
  76.  
  77.         ;move to next option
  78.  
  79. a2:
  80.         pull cx    ;restore loop count
  81.         add bx,2    ;move to next option
  82.         loop a1    ;decrement loop count
  83.         call write_command_line    ;write remainder of options
  84.  
  85.         ;write neighbour and current boxes to screen
  86.  
  87.         mov b err,5    ;set stem flags
  88.         mov cx,4    ;assume there is a neighbour box
  89.         cmp w routes,0    ;is there?
  90.         jne >a1    ;load stem character for lead to
  91.             ;neighbour box if there is
  92.         mov cx,6    ;load stem count
  93.         mov b err,0    ;indicate no leading box
  94.  
  95.         ;load stem character for lead to neighbour box
  96.  
  97. a1:
  98.         cmp cx,4    ;is there a leading box?
  99.         jne >a1    ;move cursor row coordinate if not
  100.         mov ax,w routes    ;load neighbour box
  101.         xor bx,bx    ;load element
  102.         call get_box_par    ;get neighbour of neighbour box
  103.         or ax,ax    ;is there one?
  104. if e        and b err,4    ;indicate no leading stem to leading box
  105.  
  106.         ;calculate length of leading stem
  107.  
  108. a1:
  109.         test b err,1    ;is there a leading stem to leading box?
  110. if e        inc cx    ;increment size of stem if not
  111.         sub cx,w cursor_pos+1    ;calculate length of leading stem
  112.         mov dx,b cursor_pos    ;load starting row
  113.         add w cursor_pos+1,cx    ;add length of stem to row marker
  114.         test b err,1    ;is there a leading stem to leading box?
  115.         je >a1    ;check if there is a leading stem to
  116.             ;centre box if not
  117.  
  118.         ;write leading stem to leading box to screen
  119.  
  120.         call write_stem    ;write stem to screen
  121.         inc b cursor_pos+1    ;increment cursor row
  122.         call cursor    ;position cursor
  123.         mov al,208    ;load bottom stem character
  124.         call write_chr    ;write it to bottom of leading stem
  125.  
  126.         ;write leading box to screen
  127.  
  128. a1:
  129.         test b err,4    ;is there a leading stem to centre box?
  130.         je >b1    ;
  131.         mov ax,w routes    ;load neighour box of current box
  132.         mov bx,ax
  133.         mov cx,4    ;indicate box is leading box
  134.         mov w main_route,0    ;clear route
  135.         call write_box    ;write box to screen
  136.  
  137.         ;write route and subchart indicators to stem
  138.  
  139.         test b err,4    ;is there a leading stem to current box?
  140. if ne        call write_indicator    ;write stem chr and indicator string
  141.  
  142.         ;write remainder of leading stem to screen
  143.  
  144. b1:
  145.         mov cx,4    ;calcuate length of leading stem
  146.         sub cx,w stem_start
  147.         mov dx,w cursor_pos    ;load cursor coords for rest of stem
  148.         add w cursor_pos+1,cx    ;add it to row coordinate
  149.         inc w cursor_pos+1    ;increment row coordinate
  150.         test b err,4    ;is there a leading stem?
  151.         je >b1    ;increment row coordinate if not
  152.  
  153.         ;write leading stem to current box to screen
  154.  
  155.         call write_stem    ;write stem to screen
  156.         call cursor    ;position cursor
  157.         mov al,208    ;load bottom stem character
  158.         call write_chr    ;write it to bottom of stem
  159.  
  160.         ;store centre box
  161.  
  162. b1:
  163.         mov w centre_box,bp    ;store it as current box
  164.         mov ax,w insert_mode    ;is box being inserted?
  165.         mul w box_save
  166.         or ax,dx
  167.         je >a1    ;clear descripter string buffer if not
  168.         cmp w key_option,0    ;is there a key option?
  169.         jne >a1    ;clear descripter string buffer if not
  170.         mov ax,w box_save    ;copy main box as centre box
  171.         mov w centre_box,ax
  172.  
  173.         ;clear descripter string buffer
  174.  
  175. a1:
  176.         mov dx,w link_box    ;load link box
  177.         mov di,o descripter_string    ;load offset to buffer
  178.         cmp w key_option,0    ;is there a key option?
  179.         jne >a1    ;copy route string if there is
  180.         cmp b link_string,0    ;is there a link string?
  181.         jne >b1    ;copy box decripter string if there is
  182.         mov ax,w box_save    ;load main box
  183.         or ax,ax    ;is flowchart dormant?
  184.         je >a1    ;copy route string if it is
  185.         cmp ax,bp    ;is current box main box?
  186.         jne >b1    ;copy box descripter string if not
  187.  
  188.         ;copy route string to descripter string buffer
  189.  
  190. a1:
  191.         mov si,o route_string    ;load offset to string
  192.         lodsw    ;copy characters from it
  193.         or al,al    ;is string empty?
  194.         je >a1    ;load centre box if it is
  195.         stosw
  196.         lodsb
  197.         stosb    ;write character to descripter buffer
  198. a1:
  199.         mov dx,w centre_box    ;load centre box
  200.  
  201.         ;store box descripter in buffer
  202.  
  203. b1:
  204.         mov w view_box,dx    ;store it
  205.         mov ax,' :'    ;load separator character
  206.         stosw    ;store it in descripter string
  207.         mov ax,w centre_box    ;load centre box
  208.         call get_box_descripter    ;copy box descripter string
  209.         rep
  210.         movsb    ;copy box descripter string
  211.         mov ds,ax,cs    ;restore data segment register
  212.  
  213.         ;calculate size of descripter string
  214.  
  215.         sub di,o descripter_string    ;calculate length of string
  216.         mov w descripter_count,di    ;save it
  217.         mov dx,bp    ;load current box
  218.         mov di,2    ;load loop flag
  219.         mov b err,0    ;clear box flags
  220.         mov w main_route,0    ;clear forced routes
  221.         mov w follow_route,0
  222.  
  223.         ;check if flowchart is dormant
  224.  
  225.         mov ax,w insert_mode    ;load flowchart dormant flag
  226.         or ax,ax    ;is it?
  227.         je >c1    ;calculate routes for boxes if not
  228.         cmp ax,1    ;is user choosing route for inserted box
  229.         je >a1    ;copy main box if yes
  230.         mov ax,w route    ;load current route
  231.         mov w follow_route,ax    ;store it as forced route
  232.         mov w main_route,ax
  233.         jmp >c1    ;write remaining boxes to screen
  234. a1:
  235.         mov dx,w box_save    ;load main box
  236.  
  237.         ;calculate following routes for remaining boxes
  238.  
  239. c1:
  240.         mov ax,dx    ;load box being written to screen
  241.         call get_routes    ;copy its routes
  242.         mov si,no    ;load route element
  243.         cmp w follow_route,0    ;has a route been found?
  244.         jne >b1    ;save it if it has
  245.  
  246.         ;find a next route
  247.  
  248. a1:
  249.         mov bx,w[si+routes]    ;load route of box
  250.         mov ax,dx    ;load box
  251.         call get_route    ;got box of route
  252.         or ax,ax    ;is there a route?
  253. if ne        mov w follow_route,si    ;save route element if it is
  254.         dec si,2    ;move back a route
  255.         jne a1    ;decrement loop count
  256.  
  257.         ;check if there is a route
  258.  
  259. b1:
  260.         cmp w follow_route,0    ;is there a route?
  261.         je >b3    ;copy descripter for centre box if not
  262. b2:
  263.         cmp di,1    ;is it second loop?
  264.         je >b1    ;indicate trailing stem if it is
  265.  
  266.         ;indicate two more boxes to write
  267.  
  268.         or b err,1    ;indicate there is a following stem from
  269.         mov bx,w follow_route    ;load route
  270.         mov ax,dx    ;load centre box
  271.         call get_box_par    ;get route of following stem
  272.         mov bx,ax    ;load centre box
  273.         mov ax,dx    ;load box
  274.         call get_route    ;get its route
  275.  
  276.         ;decrement loop count
  277.  
  278.         mov w box_of_route,dx    ;store box of main route
  279.         dec di    ;decrement loop count
  280.         cmp ax,dx    ;is route from copied subchart?
  281. if e        mov ax,w subchart_link    ;load following box from subchart if yes
  282.         or ax,ax    ;is there a route from copied subchart?
  283. if e        mov ax,dx    ;restore route if not
  284.         mov w trailing_box,ax    ;save following box
  285.         mov dx,ax    ;copy following box
  286.         mov w follow_route,0    ;clear its following route
  287.         jmp c1    ;goto start of loop
  288.  
  289.         ;indicate following stem from following box
  290.  
  291. b1:
  292.         or b err,2    ;indicate stem for following box
  293. b3:
  294.         mov ax,w centre_box    ;calculate centre box number
  295.         sub ax,first_box-1
  296.         call store_number    ;store it at start of buffer
  297.         mov si,o link_string    ;load offset to start of link string
  298. a1:
  299.         lodsb    ;read character from link string
  300.         or al,al    ;last character?
  301.         je >b1    ;write centre box if it is
  302.         stosb    ;write character to end of buffer
  303.         jmp a1    ;read next character
  304.  
  305.         ;write centre box to screen
  306.  
  307. b1:
  308.         mov w box,dx    ;save centre box
  309.         mov ax,dx
  310.         mov bx,w centre_box    ;load centre box
  311.         mov cx,1    ;indicate box is centre box
  312.         call write_box    ;write centre box to screen
  313.  
  314.         ;write trailing stem from centre box
  315.  
  316.         call write_indicator    ;write indicator string below box
  317.         test b err,1    ;is there a following box?
  318.         je >b1    ;write message to bottom line if not
  319.         inc w stem_start    ;move down a row
  320.         call connect    ;write trailing stem to following box
  321.         mov ax,w box    ;load following box
  322.         mov bx,w trailing_box    ;load its route from centre box
  323.         mov cx,2    ;indicate box is trailing box
  324.         mov w main_route,0    ;clear route
  325.         call write_box    ;write box to screen
  326.  
  327.         ;check if there is a trailing stem from trailing box
  328.  
  329.         call write_indicator    ;write indicator string below box
  330.         test b err,2    ;is there?
  331.         je >b1    ;write message if not
  332.         inc w stem_start    ;increment stem count
  333.         call connect    ;write trailing stem from trailing box
  334.  
  335.         ;write message to bottom of screen
  336.  
  337. b1:
  338.         cmp b message,0    ;is there a bottom line message
  339.         je ret    ;exit if not
  340.         mov dx,24*256+79    ;load cursor row and screen width-1
  341.         mov cx,w message_length    ;load size of message
  342.         sub dl,cl    ;calculate cursor column
  343.         shr dl,1
  344.         call cursor    ;position cursor
  345.         mov si,o message    ;load offset to message store
  346. a1:
  347.         lodsb    ;load character from message string
  348.         call write_chr    ;write it to screen
  349.         loop a1    ;decrement loop count
  350.         ret    ;exit
  351.  
  352.         ;fetch keypress and execute option
  353.  
  354. do_option:
  355.         call key    ;get keypress
  356.         jc >b1    ;exit if middle 5 down
  357.         jne >a1    ;make keypress upper case if not escape
  358.         cmp w box_save,0    ;is flowchart dormant?
  359.         jne do_option    ;fetch another keypress if not
  360. b1:
  361.         mov b chart_flag,3    ;indicate flowchart initialised
  362.         mov w current_box,bp    ;save current box
  363.         ret    ;exit to main loop
  364.  
  365.         ;check if middle 5 has been pressed for the second time
  366.  
  367. a1:
  368.         cmp al,02dh    ;is keypress '-'?
  369. if e        not b direct_video    ;toggle screen output flag
  370.  
  371.         ;check for HOME key
  372.  
  373.         cmp ax,04700h    ;is keypress home key?
  374.         jne >a1    ;check for letter if not
  375.         push bp    ;save current box
  376.         call move_to_first_box    ;move to first box in chart
  377.         pull bp    ;restore current box
  378.         stc    ;goto start of chart loop
  379.         ret    ;exit
  380.  
  381.         ;check if keypress is ALT-n
  382.  
  383. a1:
  384.         xor bx,bx    ;clear base register
  385.         mov bl,ah    ;load keypress
  386.         sub bl,03bh    ;is it below ALT-1?
  387.         jc >a1    ;check if character is a digit if it is
  388.         cmp bx,9    ;is it above ALT-9?
  389.         ja >a1    ;check if character is a digit if it is
  390.         shl bx,1    ;calculate offset to bookmark
  391.         mov w[bx+bookmarks],bp    ;set bookmark
  392.         jmp do_option    ;get next keypress
  393.  
  394.         ;check if keypress is a digit key (goto bookmark)
  395.  
  396. a1:
  397.         mov bl,al    ;load keypress
  398.         sub bx,'0'    ;calculate offset to bookmarks
  399.         jc >a1    ;check for other options if not digit
  400.         sub bx,1    ;is it '0'?
  401. if c        mov bx,9    ;load 10 as bookmark
  402.         cmp bx,9    ;is character a digit?
  403.         ja >a1    ;check other options if not
  404.         shl bx,1    ;calculate offset to table
  405.         mov ax,w[bx+bookmarks]    ;load bookmark
  406.         or ax,ax    ;is it set to a box
  407.         je do_option    ;get another keypress if not
  408.  
  409.         ;check if box is still active
  410.  
  411.         push ax    ;save box id
  412.         xor bx,bx    ;load offset to neighbour route
  413.         call get_box_par    ;get its leading neighbour box
  414.         cmp ax,-1    ;is there one?
  415.         pull ax    ;restore box of bookmark
  416.         je do_option    ;get another keypress if not
  417.         cmp b option_array+34,0    ;is goto box option available?
  418.         je do_option    ;get another keypress if not
  419.         mov bp,ax    ;load box of bookmark
  420.         jmp goto_box    ;goto box
  421.  
  422.         ;check if keypress is route arrow key
  423.  
  424. a1:
  425.         and al,05fh    ;make it upper case
  426.         mov es,bx,cs    ;copy code segment
  427.         mov di,o akeys    ;load offset to key values
  428.         mov cx,3    ;load route key count
  429.         repne
  430.         scasw    ;is keypress a arrow key?
  431.         jne >a1    ;check if it is alpha if not
  432.  
  433.         ;check if ok for cursor keys
  434.  
  435.         cmp w key_option,0    ;is user choosing a route?
  436.         je >a3    ;check if route for key is available
  437. e1:
  438.         jmp do_option    ;get another keypress if yes
  439. a3:
  440.         xor bx,bx    ;clear entry register
  441.         jcxz >a2    ;check if previous option is available
  442.             ;if key is up key
  443.  
  444.         ;check if arrow key route options are available
  445.  
  446.         cmp w[di+akey_jump_offset],bx    ;is arrow route available?
  447.         je e1    ;get another keypress if not
  448.         jmp w[di+akey_jump_offset]    ;move to arrow box route
  449.  
  450.         ;check if previous route option is available
  451.  
  452. a2:
  453.         cmp w option_array+18,bx    ;is previous option available?
  454.         je e1    ;get another keypress if not
  455.         jmp move_to_route    ;move to leading neighbour box
  456.  
  457.         ;check if keypress is alpha
  458.  
  459. a1:
  460.         cmp al,'A'    ;is keypress upper alpha
  461.         jb e1    ;fetch another keypress if not
  462.         cmp al,'Z'    ;is keypress upper alpha?
  463.         ja e1    ;exit if not
  464.  
  465.         ;check if keypress is a option
  466.  
  467.         mov cx,option_count+1    ;load all options count
  468.         mov di,o keys    ;load offset to key data
  469.         repne
  470.         scasb    ;is keypress a option?
  471.         jne e1    ;fetch another keypress if not
  472.         sub di,o keys    ;calculate offset to option data
  473.         shl di,1
  474.         lea di,[di+option_array]    ;calculate offset to options
  475.         cmp b[di],0    ;is option available?
  476.         je e1    ;fetch another keypress if not
  477.  
  478.         ;calculate selected option indicator
  479.  
  480.         cmp b[di],1    ;is selected option existing route?
  481.         jbe >b1    ;do option if not
  482.         cmp w insert_mode,0    ;is flowchart dormant?
  483. if e        add di,(option_count-5)*2    ;load select route option if it is
  484.  
  485.         ;jump to option routine address
  486.  
  487. b1:
  488.         xor bx,bx    ;load parameter for route options
  489.         jmp w[di+option_jump_offset]    ;jmp to address
  490.  
  491.         ;end
  492.